﻿using System;
using System.Collections.Generic;
using GameData;


public class Utils
{
    public static List<T> GetRandomList<T>(List<T> inputList)
    {
        //Copy to a array
        T[] copyArray = new T[inputList.Count];
        inputList.CopyTo(copyArray);

        //Add range
        List<T> copyList = new List<T>();
        copyList.AddRange(copyArray);

        //Set outputList and random
        List<T> outputList = new List<T>();
        System.Random rd = new System.Random(DateTime.Now.Millisecond);

        while (copyList.Count > 0)
        {
            //Select an index and item
            int rdIndex = rd.Next(0, copyList.Count);
            T remove = copyList[rdIndex];

            //remove it from copyList and add it to output
            copyList.Remove(remove);
            outputList.Add(remove);
        }
        return outputList;
    }



    public static int SortCompare(NumberInfo AF1, NumberInfo AF2)
    {
        int res = 0;
        if (AF1.QueueNum > AF2.QueueNum)
        {
            res = 1;
        }
        else if (AF1.QueueNum < AF2.QueueNum)
        {
            res = -1;
        }
        return res;
    }

    public static int SortCompareNum(NumqueInfo AF1, NumqueInfo AF2)
    {
        int res = 0;
        if (AF1.que > AF2.que)
        {
            res = 1;
        }
        else if (AF1.que < AF2.que)
        {
            res = -1;
        }
        return res;
    }


    public static int SortCompareByque(NumberInfo AF1, NumberInfo AF2)
    {
        int res = 0;
        if (AF1.needque > AF2.needque)
        {
            res = 1;
        }
        else if (AF1.needque < AF2.needque)
        {
            res = -1;
        }
        return res;
    }


}